iT邦幫忙

2026 iThome 鐵人賽

DAY 29
0

自動化 workflow 建立後,必須具備即時的可觀測性。本篇介紹 Prometheus 收集器與 Grafana 儀表板的整合。

1. Prometheus 配置

<JENKINS_IP> 啟動 Prometheus 容器,並配置 prometheus.yml 監控 Jenkins 與應用程式。

scrape_configs:
  - job_name: 'jenkins'
    metrics_path: '/jenkins/prometheus/'
    static_configs:
      - targets: ['<JENKINS_IP>:8080']

  - job_name: 'dotnet-apps'
    static_configs:
      - targets: ['<SERVER_IP>:5000', '<SERVER_IP>:5000']

2. Jenkins Prometheus Plugin

在 Jenkins 安裝 Prometheus metrics 外掛:

  • 提供 jenkins_executor_free_count: 監控建置節點是否滿載。
  • 提供 jenkins_builds_success_total: 統計 workflow 成功率。

3. Grafana 視覺化儀表板

建立 Grafana 容器並串接 Prometheus 資料源。

  • 訪問位址: https://ci-cd.example.com/grafana/
  • 核心 Dashboard 指標:
    • CI 狀態: 顯示過去 24 小時各專案的建置成功率。
    • 部署頻率: 統計每日觸發部署的次數。
    • 系統負載: 監控 Jenkins Agent 與目標伺服器的 CPU/RAM 使用狀況。

4. 自動化警報系統

在 Grafana 設定 Alert 規則,當 Quality Gate Fail 次數在 1 小時內超過 3 次時,發送通知給開發小組的 Email。

5. 監控對 AI 流程的意義

在程式碼量幾何增長的環境中,監控系統能及早偵測出異常的建置趨勢或部署失敗。透過數據分析,團隊能評估是否需要調整 AI 生成的規則或強化測試層面,實現數據驅動的 DevOps 管理。


上一篇
Day 28 解決 Windows 權限之痛:利用工作排程器 (Task Scheduler) 驅動遠端部署
下一篇
Day 30 永續維運與系統結語:建構自動化的未來基石
系列文
迎接 AI 開發爆發期:告別手動部署,帶領企業團隊從 Git 規範到 CI/CD 實戰30
圖片
  熱門推薦
圖片
{{ item.channelVendor }} | {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言